package org.zcl.sqlSession;

import org.dom4j.DocumentException;
import org.zcl.config.XmlConfigBuilder;
import org.zcl.pojo.Configuration;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * .
 *
 * @Author Chenglin Zhu
 * @Date 2022/3/12 17:47
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws DocumentException, PropertyVetoException {
        // 1、解析配置文件封装到对象中
        XmlConfigBuilder xmlConfigBuilder = new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(in);
        // 2、创建sqlSessionFactory对象,生产sqlSession会话对象
        return new DefaultSqlSessionFactory(configuration);
    }
}
